package com.adcdn.addemo;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.adcdn.addemo.banner.BannerActivity;
import com.adcdn.addemo.game.GameActivity;
import com.adcdn.addemo.interstitial.InterstitialActivity;
import com.adcdn.addemo.nativead.NativeExpressActivity;
import com.adcdn.addemo.splash.SplashActivity2;
import com.adcdn.addemo.video.FullVideoActivity;
import com.adcdn.addemo.video.VideoActivity;
import com.android.adcdn.sdk.kit.init.AdcdnConfig;
import com.android.adcdn.sdk.kit.init.AdcdnMobSDK;
import com.android.adcdn.sdk.kit.init.AdcdnTTConfig;
import com.android.adcdn.sdk.kit.init.AdcdnYLHConfig;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.yunxia.addemo.R;


/**
 * 首页
 */
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        findViewById(R.id.tvSplash).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SplashActivity2.jumpHere(MainActivity.this);
            }
        });
        findViewById(R.id.tvBanner).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BannerActivity.jumpHere(MainActivity.this);
            }
        });
        findViewById(R.id.tvInsert).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                InterstitialActivity.jumpHere(MainActivity.this);
            }
        });
        findViewById(R.id.tvVideo).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                VideoActivity.jumpHere(MainActivity.this);
            }
        });

        findViewById(R.id.tvNativeEx).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                NativeExpressActivity.jumpHere(MainActivity.this);
            }
        });
        findViewById(R.id.tvFullVideo).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FullVideoActivity.jumpHere(MainActivity.this);
            }
        });
        findViewById(R.id.tvGardenGame).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                GameActivity.jumpHere(MainActivity.this);
            }
        });


    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.actions, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        AdcdnConfig config = AdcdnMobSDK.instance().getConfig();
        int id = item.getItemId();
        if (id == R.id.action_download_confirm) {
            // 下载二次确认(穿山甲、优量汇)
            AdcdnTTConfig tt = config.getTTConfig();
            tt.setDownloadType(tt.getDownloadType() == TTAdConstant.DOWNLOAD_TYPE_POPUP
                    ? TTAdConstant.DOWNLOAD_TYPE_NO_POPUP : TTAdConstant.DOWNLOAD_TYPE_POPUP);

            AdcdnYLHConfig ylh = config.getYLHConfig();
            ylh.setDownloadConfirm(!ylh.isDownloadConfirm());
        } else if (id == R.id.action_splash_num) {
            // 开屏数字倒计时（穿山甲）
            AdcdnTTConfig tt = config.getTTConfig();
            tt.setSplashUseNum(!tt.getSplashUseNum());
        } else if (id == R.id.action_splash_hot) {
            // 开屏热点（穿山甲）
            AdcdnTTConfig tt = config.getTTConfig();
            tt.setSplashButtonType(tt.getSplashButtonType() == TTAdConstant.SPLASH_BUTTON_TYPE_FULL_SCREEN
                    ? TTAdConstant.SPLASH_BUTTON_TYPE_DOWNLOAD_BAR : TTAdConstant.SPLASH_BUTTON_TYPE_FULL_SCREEN);
        }
        return super.onOptionsItemSelected(item);
    }
}


